<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get the objectʼs timezone</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="intlcalendar.gettime.html">« IntlCalendar::getTime</a></li>
      <li style="float: right;"><a href="intlcalendar.gettype.html">IntlCalendar::getType »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.intlcalendar.html">IntlCalendar</a></li>
    <li>Get the objectʼs timezone</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="intlcalendar.gettimezone" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">IntlCalendar::getTimeZone</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.5.0, PHP 7, PHP 8, PECL &gt;= 3.0.0a1)</p><p class="refpurpose"><span class="refname">IntlCalendar::getTimeZone</span> &mdash; <span class="dc-title">Get the objectʼs timezone</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-intlcalendar.gettimezone-description">
  <h3 class="title">说明</h3>
  <p class="para">
   面向对象风格
  </p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>IntlCalendar::getTimeZone</strong></span>(): <span class="type"><span class="type"><a href="class.intltimezone.html" class="type IntlTimeZone">IntlTimeZone</a></span>|<span class="type"><span class="type false">false</span></span></span></div>

  <p class="para rdfs-comment">
   过程化风格
  </p>
  <div class="methodsynopsis dc-description"><span class="methodname"><strong>intlcal_get_time_zone</strong></span>(<span class="methodparam"><span class="type"><a href="class.intlcalendar.html" class="type IntlCalendar">IntlCalendar</a></span> <code class="parameter">$calendar</code></span>): <span class="type"><span class="type"><a href="class.intltimezone.html" class="type IntlTimeZone">IntlTimeZone</a></span>|<span class="type"><span class="type false">false</span></span></span></div>

  <p class="para rdfs-comment">
   Returns the <span class="classname"><a href="class.intltimezone.html" class="classname">IntlTimeZone</a></span> object associated with this
   calendar.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-intlcalendar.gettimezone-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">calendar</code></dt>

    <dd>

     <p class="para"><span class="classname"><a href="class.intlcalendar.html" class="classname">IntlCalendar</a></span> 实例。</p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-intlcalendar.gettimezone-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   An <span class="classname"><a href="class.intltimezone.html" class="classname">IntlTimeZone</a></span> object corresponding to the one used
   internally in this object.  Returns <strong><code>false</code></strong> on failure.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-intlcalendar.gettimezone-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2408">
   <p><strong>示例 #1 <span class="function"><strong>IntlCalendar::getTimeZone()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />ini_set</span><span style="color: #007700">(</span><span style="color: #DD0000">'date.timezone'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'Europe/Lisbon'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ini_set</span><span style="color: #007700">(</span><span style="color: #DD0000">'intl.default_locale'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'en_US'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$cal&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">IntlCalendar</span><span style="color: #007700">::</span><span style="color: #0000BB">createInstance</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$cal</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getTimeZone</span><span style="color: #007700">());<br /><br /></span><span style="color: #0000BB">$cal</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setTimeZone</span><span style="color: #007700">(</span><span style="color: #DD0000">'UTC'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$cal</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getTimeZone</span><span style="color: #007700">());<br /><br /></span><span style="color: #0000BB">$cal&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">IntlCalendar</span><span style="color: #007700">::</span><span style="color: #0000BB">fromDateTime</span><span style="color: #007700">(</span><span style="color: #DD0000">'2012-01-01&nbsp;00:00:00&nbsp;GMT+03:33'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$cal</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getTimeZone</span><span style="color: #007700">());</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
IntlTimeZone Object
(
    [valid] =&gt; 1
    [id] =&gt; Europe/Lisbon
    [rawOffset] =&gt; 0
    [currentOffset] =&gt; 3600000
)
IntlTimeZone Object
(
    [valid] =&gt; 1
    [id] =&gt; UTC
    [rawOffset] =&gt; 0
    [currentOffset] =&gt; 0
)
IntlTimeZone Object
(
    [valid] =&gt; 1
    [id] =&gt; GMT+03:33
    [rawOffset] =&gt; 12780000
    [currentOffset] =&gt; 12780000
)
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-intlcalendar.gettimezone-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="intlcalendar.settimezone.html" class="methodname" rel="rdfs-seeAlso">IntlCalendar::setTimeZone()</a> - Set the timezone used by this calendar</span></li>
    <li class="member"><span class="methodname"><a href="intlcalendar.createinstance.html" class="methodname" rel="rdfs-seeAlso">IntlCalendar::createInstance()</a> - Create a new IntlCalendar</span></li>
    <li class="member"><span class="methodname"><a href="intlgregoriancalendar.construct.html" class="methodname" rel="rdfs-seeAlso">IntlGregorianCalendar::__construct()</a> - Create the Gregorian Calendar class</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>